import request from '@/utils/request'
enum API {
  ALLUSER_URL = '/admin/acl/user/',
  ADDUSER_URL = '/admin/acl/user/save',
  UPDATEUSER_URL = '/admin/acl/user/update',
  ALLROLE_URL = '/admin/acl/user/toAssign/',
  SETUSERROLE_URL = '/admin/acl/user/doAssignRole',
  BATCHDELETE_URL = '/admin/acl/user/batchRemove'
}
export const reqUserList = (page: number, limit: number, username: string) => {
  return request.get<any, any>(API.ALLUSER_URL + `${page}/${limit}/?username=${username}`)
}
export const reqAddOrUpdateUser = (data: any) => {
  if (data.id) {
    return request.put<any, any>(API.UPDATEUSER_URL, data)
  } else {
    return request.post<any, any>(API.ADDUSER_URL, data)
  }
}
export const reqAllRole = (adminId: string) => {
  return request.get<any, any>(API.ALLROLE_URL + `${adminId}`)
}
export const reqSetRole = (data: any) => {
  return request.post<any, any>(API.SETUSERROLE_URL, data)
}
export const reqBatchDeleteUser = (idList: any) => {
  return request({
    method: 'delete',
    url: API.BATCHDELETE_URL,
    data: {
      idList
    }
  })
}
